#include <stddef.h>

void *bcd2ascii(void* dst, const void* src, size_t n);

static const unsigned char inp[] = {
    0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,   //  8
    0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,   // 16
    0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,   // 24
    0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,   // 32
    0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,   // 40
    0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,   // 48
    0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,   // 56
    0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10    // 64
};

#include <stdio.h>

int main()
{
    char out[sizeof inp * 2 + 1] = {0};
    // expected output:
    // out = { '0', '1', '2', '3', ... }

    bcd2ascii(out, inp, sizeof inp);
    puts(out);
    for (size_t i = 1; i < sizeof inp + 1; ++i) {
        __builtin_memset(out, 0, sizeof out);
        bcd2ascii(out, inp, sizeof inp-i);
        puts(out);
    }
    return 0;
}
